<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header">
    <title>积分审批</title>
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="integralApproval-form">
					<div class="select-list">
						<ul>
							<li>
								<label>员工姓名： </label><input type="text" name="userName"/>
							</li>
							<li>
								<label>部门名称： </label><select name="userDeptId" th:with="dept=${@dept.getDept()}" class="form-control m-b-none">
								<option value="">所有</option>
								<option th:each="dept : ${dept}" th:text="${dept.deptName}" th:value="${dept.deptId}"></option>
							</select>
							</li>
							<li>
								<label>职位名称： </label><select name="userPostId" th:with="post=${@post.getPost()}" class="form-control m-b-none">
								<option value="">所有</option>
								<option th:each="post : ${post}" th:text="${post.postName}" th:value="${post.postId}"></option>
							</select>
							</li>
							<li>
								<label>审批状态： </label><select name="status" class="form-control m-b-none">
								<option value="">所有</option>
								<option value="0">审批中</option>
								<option value="1">已通过</option>
								<option value="2">未通过</option>
								<option value="3">已撤销</option>
							</select>
							</li>
							<li>
								<label>积分类型： </label><select name="typeId" class="form-control m-b-none">
								<option value="">所有</option>
								<option value="">品德A分</option>
								<option value="">业绩B分</option>
								<option value="">行为C分</option>
							</select>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<!--<div class="col-sm-12 search-collapse">-->
			<!---->
			<!--</div>-->
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="integral:integralApproval:add">
                    <i class="fa fa-plus"></i> 添加
                </a> -->
				<!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="integral:integralApproval:edit">-->
				<!--<i class="fa fa-edit"></i> 修改-->
				<!--</a>-->
				<!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="integral:integralApproval:remove">-->
				<!--<i class="fa fa-remove"></i> 删除-->
				<!--</a>-->
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('integral:integralApproval:edit')}]];
        var detailFlag = [[${@permission.hasPermi('integral:integralApproval:detailFlag')}]];
        var removeFlag = [[${@permission.hasPermi('integral:integralApproval:remove')}]];
        var successYes = [[${@permission.hasPermi('integral:integralApproval:success')}]];
        var prefix = ctx + "integral/integralApproval";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                detailUrl: prefix + "/detail/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                approvalUrl: prefix + "/success/{id}/{state}",
                modalName: "审批管理",
                columns: [{
                    checkbox: true
                },
                    // {
                    //     field : 'approvalId',
                    //     title : '审批序号'
                    // },
					{
					    formatter: function (value, row, index) {
							return index+ 1;
                        }
					},
                    {
                        field : 'approvalNum',
                        title : '审批编号'
                    },
                    {
                        field : 'approvalTitle',
                        title : '审批标题',
                        width : 204
                    },
                    // {
                    //     field : 'approvalContent',
                    //     title : '审批内容'
                    // },
                    // {
                    //     field : 'userId',
                    //     title : '关联用户id'
                    // },
                    {
                        field : 'userName',
                        title : '获得积分员工'
                    },
                    {
                        field : 'userImg',
                        title : '获得积分员工头像',
                        formatter: function(value, row, index) {
                            if (value) {
                                return `<img src=${value} width="100" height="100"></img>`
                            } else {
                                return '没有上传头像'
                            }
                        }
                    },
                    // {
                    //     field : 'userPhone',
                    //     title : '申请人电话也是唯一标识'
                    // },
                    // {
                    //     field : 'userDept',
                    //     title : '所属部门'
                    // },
                    // {
                    //     field : 'userDeptId',
                    //     title : '部门id'
                    // },
                    // {
                    //     field : 'userPostId',
                    //     title : '职位id'
                    // },
                    // {
                    //     field : 'userPost',
                    //     title : '员工职位'
                    // },
                    {
                        field : 'tiJiaoName',
                        title : '提交申请员工'
                    },
                    {
                        field : 'tiJiaoNameImg',
                        title : '提交申请员工头像',
                        formatter: function(value, row, index) {
                            if (value) {
                                return `<img src=${value} width="100" height="100"></img>`
                            } else {
                                return '没有上传头像'
                            }
                        }
                    },
                    {
                        field : 'typeId',
                        title : '积分类型',
						formatter: function (value, row, index) {
							switch (value) {
								case 1: return '品德A分';
								case 2: return '业绩B分';
								case 3: return '行为C分';
                            }
                        }
                    },
                    {
                        field : 'sqIntegral',
                        title : '申请积分'
                    },
                    {
                        field : 'sqTime',
                        title : '申请时间',
                        sortable: true
                    },
                    {
                        field : 'spTime',
                        title : '审批时间',
                        sortable: true
                    },
                    {
                        field : 'status',
                        title : '审批转态',
						formatter: function (value) {
							switch (value) {
								case 0: return '<span class="badge badge-danger">未审批</span>';
								case 1: return '<span class="badge badge-info">已通过</span>';
								case 2: return '<span class="badge badge-success">未通过</span>';
								case 3: return '<span class="badge badge-important">已撤销</span>';
                            }
                        }
                    },
                    // {
                    //     field : 'sqIntegral',
                    //     title : '申请积分'
                    // },
                    // {
                    //     field : 'kIntegral',
                    //     title : '扣积分'
                    // },
                    // {
                    //     field : 'spRemark',
                    //     title : '审批备注'
                    // },
                    // {
                    //     field : 'approvalTime',
                    //     title : '申请时间'
                    // },
                    // {
                    //     field : 'approvalImg1',
                    //     title : '上传图片1'
                    // },
                    // {
                    //     field : 'approvalImg2',
                    //     title : '上传图片2'
                    // },
                    // {
                    //     field : 'approvalImg3',
                    //     title : '上传图片3'
                    // },
                    // {
                    //     field : 'approvalImg4',
                    //     title : '上传图片4'
                    // },
                    // {
                    //     field : 'approvalImg5',
                    //     title : '上传图片5'
                    // },
                    // {
                    //     field : 'approvalImg6',
                    //     title : '上传图片6'
                    // },
                    // {
                    //     field : 'approvalImg7',
                    //     title : '上传图片7'
                    // },
                    // {
                    //     field : 'approvalImg8',
                    //     title : '上传图片8'
                    // },
                    // {
                    //     field : 'approvalImg9',
                    //     title : '上传图片9'
                    // },
                    // {
                    //     field : 'remark',
                    //     title : '备注'
                    // },



		        {
		            title: '操作',
		            align: 'center',
					width: 300,
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.approvalId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
               //          actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.approvalId + '\')"><i class="fa fa-remove"></i>删除</a>');
               //          actions.push('<a class="btn btn-info btn-xs ' + successYes + '" href="#" onclick="$.operate.approval(\'' + row.approvalId+'\',\''+row.tiJiaoName + '\')"><i class="fa fa-key"></i>审批</a>');

                        if (row.status == '0') {
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="$.operate.editDetail(\'' + row.approvalId + '\')"><i class="fa fa-search"></i>查看</a> ');
                            actions.push('<a class="btn btn-primary btn-xs ' + successYes + '" href="#" onclick="$.operate.approval(\'' + row.approvalId+'\',1)"><i class="fa fa-key"></i>审批通过</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + successYes + '" href="#" onclick="$.operate.approval(\'' + row.approvalId+'\',2)"><i class="fa fa-key"></i>审批不过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.removeApproval(\'' + row.approvalId + '\',3)"><i class="fa fa-remove"></i>撤销审批</a> ');
                        }
                        else {
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="$.operate.editDetail(\'' + row.approvalId + '\')"><i class="fa fa-search"></i>查看</a> ');
                        }

                        // actions.push('<a class="btn btn-danger btn-xs ' + successYes + '" href="#" onclick="success(\'' + row.approvalId + '\')"><i class="fa fa-edit"></i>审批通过</a>');

                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        /** 审批通过*/
        // function success(approvalId) {
        //     var url = prefix + '/success/' + approvalId;
        //     $.modal.open("离职员工",url,'300','200');
        // }
    </script>
</body>
</html>